<?php


namespace App\Service\Bank;

use App\Constants\XZXResponseCode;
use App\Utils\CustomUtils;
use Hyperf\Utils\Arr;
use PHPUnit\Framework\MockObject\CannotUseAddMethodsException;

/**
 * Class BankTestService
 * 测试银行网关
 *
 * @package App\Service\Bank
 */
class BankTestService implements IBankInterface {

    /**
     * @inheritDoc
     */
    public function doPay ($params, $channel, $bank) {

        if (Arr::get($params, 'payAccount.forceBankFail', false)) {
            $ret = CustomUtils::buildError(trans('bank.debug.fail'), XZXResponseCode::FAILED_CODE, ['isBankFail' => true]);
        }
        else {
            $data = [
                'relNo' => date('YmdHis').rand(1000, 9999),
            ];

            $ret = CustomUtils::buildSuccess($data, trans('bank.send_success'));
        }

        return $ret;
    }

    /**
     * @inheritDoc
     */
    public function doRefund ($params, $channel, $bank) {

        $data = [];

        return CustomUtils::buildSuccess($data, trans('bank.send_success'));
    }

    /**
     * @inheritDoc
     */
    public function doTransfer ($params, $channel, $bank) {

        $data = [];

        return CustomUtils::buildSuccess($data, trans('bank.send_success'));
    }

    /**
     * @inheritDoc
     */
    public function doOrderQuery ($params, $channel, $bank) {
        $data = [];

        return CustomUtils::buildSuccess($data, "订单查询");
    }

    /**
     * @inheritDoc
     */
    public function doRefundQuery ($params, $channel, $bank) {
        $data = [];

        return CustomUtils::buildSuccess($data, "订单退款查询");
    }

    /**
     * @inheritDoc
     */
    public function doTransferQuery ($params, $channel, $bank) {
        $data = [];

        return CustomUtils::buildSuccess($data, "转帐查询");
    }

}
